const db=uniCloud.database()
exports.main = async (event, context) => {
	let {detail} = event;
	let {id}=event;
	let {newimg}=event;
	
	if(event.api==='submit'){
			return await db.collection('article').add({
				posttime:Date.now(),
				...detail
			})
		}
		
		if(event.api==='rm'){
				
					return await db.collection("article").doc(id).remove()
			}
		
		if (event.api === 'update'){
			return await db.collection('article').doc(detail._id).update({
				Changedposttime:Date.now(),
				title:detail.title,
				author:detail.author,
				content:detail.content,
				img:newimg
			})
		}
};








